1 // thor magnusson (2007)
3 // Example showing how SCScope can be used in a UI
5 GUI.cocoa; // use Mac OS X native GUI
6 GUI.swing; // use Java GUI
9 s = Stethoscope.defaultServer;
12 b = Buffer.alloc(s,2048,2);
13 a = SynthDef(\scopeExample, { arg freq=400, rate=2, amp=0.4, pan=0;
15 signal = [LFSaw.ar(freq, 0, amp/2)*SinOsc.ar(rate),
16 Pulse.ar( freq, 0.51, amp)*SinOsc.ar(rate)];
17 signal = Balance2.ar(signal[0], signal[1], pan);
18 scope = if( GUI.id === \cocoa, \ScopeOut, \JScopeOut ).asClass;
19 scope.ar( signal, b );
23 w = Window("scope in a gui", Rect(100, 400, 400, 300))
24 .onClose_({a.free;}) // free synth on closing window
27 MultiSliderView(w, Rect(10, 10, 90, 120))
28 .value_([0.4, 0.5, 0.6, 0.5])
29 .indexIsHorizontal_(false)
31 .strokeColor_(Color.new255(10, 55, 10))
32 .fillColor_(Color.new255(110, 155, 110).alpha_(0.6))
38 {0} { a.set(\freq, 400+(sl.value[sl.index]*400)) }
39 {1} { a.set(\rate, (sl.value[sl.index]*10)) }
40 {2} { a.set(\amp, sl.value[sl.index]) }
41 {3} { a.set(\pan, (sl.value[sl.index]*2)-1) };
44 StaticText(w, Rect(14, 4, 90, 30))
46 StaticText(w, Rect(14, 34, 90, 30))
48 StaticText(w, Rect(14, 64, 90, 30))
50 StaticText(w, Rect(14, 94, 90, 30))
53 StaticText(w, Rect(10, 140, 90, 16))
56 Slider(w, Rect(10, 160, 90, 24))
57 .action_({|sl| sc.xZoom_(sl.value*4)});
59 sc = ScopeView(w, Rect(120,10,260,260))
61 .background_(Color.white)
63 .waveColors_([Color.black, Color.black]);